package org.wk.user.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.wk.core.common.view.PageVo;
import org.wk.core.common.view.ResponseVo;
import org.wk.user.service.UserSuggestionsService;
import org.wk.user.view.UserSuggestionsVo;

import java.util.Map;

/**
 * @author TangShenShen
 * @Description: 系统反馈建议controller
 * @date 2018/6/6 10:07
 */
@RestController
@RequestMapping("/sys/suggestions")
public class SuggestionsController {

    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private UserSuggestionsService suggestionsService;

    /**
     * 反馈意见列表
     */
    @RequestMapping("/list")
    public ResponseVo list(@RequestParam Map<String, Object> params){
        PageVo page = suggestionsService.queryPage(params);
        return ResponseVo.success().addAttribute("page", page);
    }

    /**
     * 反馈意见详细信息
     */
    @RequestMapping("/info/{id}")
    public ResponseVo info(@PathVariable("id") String id){
        UserSuggestionsVo suggestionsVo = suggestionsService.selectById(id);
        return ResponseVo.success().addAttribute ("suggestion", suggestionsVo);
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public ResponseVo list(@RequestBody String[]  sugIds){
        suggestionsService.deleteBatch(sugIds);
        return ResponseVo.success();
    }

    /*
     * @description 标识已经处理的建议
     * @param
     * @author ZhaoPing'an
     * @date 2018/7/16 14:38
     */
    @RequestMapping("/processed")
    public ResponseVo processed(@RequestBody String  id){
        suggestionsService.updateProcessed(id);
        return ResponseVo.success();
    }

}
